﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="sysMenuForm.aspx.cs" Inherits="Form_sysMenuForm" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <%--<script src="<%=ResolveClientUrl("~/Resource/js/benik.js")%>" type="text/javascript"></script>--%>
    <script language="javascript" type="text/javascript">
        $(document).ready(function () {
            $('#panelbar').kendoPanelBar();
            $("#txtTitle").focus();

            $('#btnClose').click(function () {
                parent.$('#dialog').dialog('close');
                return false;
            });


            $('#btnSave').click(function () {
                if (!$("#form1").valid())
                    return;

                var name = $('#txtTitle').val();
                var url = $('#txtUrl').val();
                var sort = $('#txtSort').val();
                var parentID = $("#ddlParent option:selected").val();
                //alert(parentID);
                var id = $('#<%= hfID.ClientID %>').val();

                var objMenu = new Object();
                objMenu.MenuID = id;
                objMenu.Title = encodeURIComponent(name);
                objMenu.Url = encodeURIComponent(url);
                objMenu.Sort = encodeURIComponent(sort);
                objMenu.ParentID = encodeURIComponent(parentID);
                jsonData = JSON.stringify(objMenu);

                 if (id == 0)
                     CallAjax('<%= ResolveUrl("~/handler/sysMenuHandler.ashx") %>', "?show=create", jsonData);
                 else
                    CallAjax('<%= ResolveUrl("~/handler/sysMenuHandler.ashx") %>', "?show=update", jsonData);

                 parent.$('#dialog').dialog('close');
                 //parent.location.reload();
                //setTimeout(parent.$('#menu-grid').data('kendoGrid').dataSource.read(), 3000);
                //setTimeout(parent.$('#menu-grid').data('kendoGrid').refresh(), 3000);
                return false;
            });
        });

    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div class="grid-box" id="menuform">
        <h3 id="h3Title" runat="server">
        </h3>
        <input type="hidden" name="ID" />
        <ul id="panelbar">
            <li class="k-state-active">Data Menu
                <div class="forminput">
                    <table width="100%" style="background: #FFF; padding: 10px">
                        <tr>
                            <td>
                                <label for="txtTitle">
                                    Title</label>
                            </td>
                            <td>
                                <%--<input type="text" class="required" name="Title" size="40" />--%>
                                <asp:TextBox ID="txtTitle" runat="server" CssClass="required" MaxLength="40" Width="200"> </asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td width="150">
                                <label for="ParentID">
                                    Parent</label>
                            </td>
                            <td>
                                <%--<input type="text" class="combo" name="ParentID" data-cache="MenuID,Title" data-bind="../Handler/sysMenuHandler.ashx?type=combo" />--%>
                                <asp:DropDownList ID="ddlParent" runat="server" CssClass="combo" Width="200" ></asp:DropDownList>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <label for="txtUrl">
                                    URL</label>
                            </td>
                            <td>
                                <%--<input type="text" class="required" name="Url" size="70" />--%>
                                <asp:TextBox ID="txtUrl" runat="server" CssClass="required" MaxLength="70" Width="200"></asp:TextBox>
                            </td>
                            
                        </tr>
                        <tr>
                        <td>
                                <label for="txtSort">
                                    Sort</label>
                            </td>
                            <td>
                                <%--<input type="text" class="numeric required" name="Sort" size="2" />--%>
                                <asp:TextBox ID="txtSort" runat="server" CssClass="numeric required" MaxLength="2" Width="50"></asp:TextBox>
                            </td>
                        </tr>
                    </table>
                </div>
            </li>
        </ul>

         <button id="btnClose" type="button">
                        Close</button>
        <button id="btnSave" type="button">
                        Save</button>
    </div>

    <asp:HiddenField ID="hfID" runat="server" Value="" />
    </form>
</body>
</html>
